package com.symone.webcms.schedule.job;

import com.symone.webcms.model.ScheduleTask;
import com.symone.webcms.service.ScheduleTaskService;
import com.symone.webcms.util.SpringUtil;
import org.quartz.SchedulerException;

import java.util.List;

public class JobViewTest {

    private ScheduleTaskService taskService;

    public JobViewTest() {
        taskService = (ScheduleTaskService) SpringUtil.getBean(ScheduleTaskService.class);
    }

    public void run() {
        List<ScheduleTask> jobs;
        try {
            System.out.print("All jobs: ");
            jobs = taskService.getAllJobs();
            for (ScheduleTask job : jobs) {
                System.out.print(job.getGroup() + "_" + job.getName() + " " + job.getStatus() + "\t");
            }
            System.out.println();
        } catch (SchedulerException e) {
            e.printStackTrace();
        }
    }
}
